import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:kkhousekeep/widget/custom_date_picker.dart';

class CupertinoActionSheetActionModel {
  final String content;
  final VoidCallback callBack;

  CupertinoActionSheetActionModel(this.content, this.callBack);
}

class CustomDialog {
  static Widget customCupertinoActionSheet(
      List<CupertinoActionSheetActionModel> actionModelList) {
    return CupertinoActionSheet(
      actions: actionModelList
          .map((actionModel) =>
              buildActionWidget(actionModel.content, actionModel.callBack))
          .toList(),
      cancelButton: CupertinoActionSheetAction(
        onPressed: () {
          Get.back();
        },
        child: Text(
          "取消",
          style: TextStyle(fontSize: 34.sp, color: const Color(0xFFDD5045)),
        ),
      ),
    );
  }

  static Widget buildActionWidget(String content, VoidCallback voidCallback) {
    return Container(
      color: Colors.white,
      child: CupertinoActionSheetAction(
        onPressed: voidCallback,
        child: Text(
          content,
          style: TextStyle(fontSize: 34.sp, color: const Color(0xFF222222)),
        ),
      ),
    );
  }

  static Widget dataPicker(ValueChanged timeChangedCallBack) {
    return SizedBox(
      height: 600.h,
      child: CustomCupertinoDatePicker(
        onDateTimeChanged: timeChangedCallBack,
        mode: CupertinoDatePickerMode.date,
        minuteInterval: 1,
        backgroundColor: Colors.white,
        dateOrder: DatePickerDateOrder.ymd,
        itemExtent: 96.h,
        pickerHeight: 600.h,
        cancelCallBack: () => Get.back(),
        confirmCallBack: () => Get.back(),
        customSelectionOverlay: IgnorePointer(
          child: Center(
            child: Container(
              decoration: const BoxDecoration(
                border: Border(
                  top: BorderSide(
                    width: 0.0,
                    color: Color(0xFFD0D0D0),
                  ),
                  bottom: BorderSide(
                    width: 0.0,
                    color: Color(0xFFD0D0D0),
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
